package com.xmut.mall.manager.service.impl;

import com.xmut.mall.manager.dto.StatisticsQueryParam;
import com.xmut.mall.manager.service.IndexStatisticsService;
import com.xmut.mall.manager.utils.RespBean;
import com.xmut.mall.manager.vo.IndexNoticeVO;
import com.xmut.mall.manager.vo.IndexStatisticsVO;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

@Service
public class IndexStatisticsServiceImpl implements IndexStatisticsService {

    /**
     * 获取当前后台待办事项
     * @return
     */
    @Override
    public RespBean notice() {
        // 暂未实现 先给0
        IndexNoticeVO indexNoticeVO = new IndexNoticeVO();
        //商品审核
        indexNoticeVO.setGoods(1l);
        //店铺入驻审核
        indexNoticeVO.setStore(0l);
        //售后申请
        indexNoticeVO.setRefund(0l);
        //投诉审核
        indexNoticeVO.setComplain(0l);
        //分销员提现审核
        indexNoticeVO.setDistributionCash(0l);
        //待处理商家结算
        indexNoticeVO.setWaitPayBill(0l);
        return RespBean.success("获取成功",indexNoticeVO);
    }

    /**
     * 获取首页的具体数据
     * @return
     */
    @Override
    public RespBean HomeData() {
        // 没时间了随便写点
        //首页统计内容
        IndexStatisticsVO indexStatisticsVO = new IndexStatisticsVO();

        //获取总订单数量
        indexStatisticsVO.setOrderNum(10l);
        //获取总会员数量
        indexStatisticsVO.setMemberNum(1000l);
        //获取总上架商品数量
        indexStatisticsVO.setGoodsNum(100l);
        //获取总店铺数量
        indexStatisticsVO.setStoreNum(23l);

        //下单统计
//        Map<String, Object> map = storeFlowStatisticsService.getOrderStatisticsPrice();
        Map<String, Object> map = new HashMap<>();
        map.put("num",100l);
        map.put("price",100000D);
        //今日下单数
        indexStatisticsVO.setTodayOrderNum(map.get("num") == null ? 0L : (Long) map.get("num"));
        //今日下单金额
        indexStatisticsVO.setTodayOrderPrice(map.get("price") == null ? 0D : (Double) map.get("price"));

        //今日新增会员数量
        indexStatisticsVO.setTodayMemberNum(1000l);
        //今日新增商品数量
        indexStatisticsVO.setTodayGoodsNum(200l);
        //今日新增店铺数量
        indexStatisticsVO.setTodayStoreNum(12l);
        //今日新增评论数量
        indexStatisticsVO.setTodayMemberEvaluation(10000l);
        //当前在线人数
        indexStatisticsVO.setCurrentNumberPeopleOnline(20000l);


        //流量统计
        StatisticsQueryParam queryParam = new StatisticsQueryParam();

        //今日uv
//        queryParam.setSearchType(SearchTypeEnum.TODAY.name());
        indexStatisticsVO.setTodayUV(10000);

//       昨日访问数UV
//        queryParam.setSearchType(SearchTypeEnum.YESTERDAY.name());
        indexStatisticsVO.setYesterdayUV(9600);

//       前七日访问数UV
//        queryParam.setSearchType(SearchTypeEnum.LAST_SEVEN.name());
        indexStatisticsVO.setLastSevenUV(100000);

//       三十日访问数UV
//        queryParam.setSearchType(SearchTypeEnum.LAST_THIRTY.name());
        indexStatisticsVO.setLastThirtyUV(1000000);


        return RespBean.success("获取成功",indexStatisticsVO);

    }
}
